#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/mman.h>

#include <iostream>

int main(int argc, char* argv[])
{

    int fd = open("/dev/hello", O_RDWR, S_IRUSR|S_IWUSR);
    if(fd != -1)
    {
	void* addr = mmap(nullptr, 1024, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 8192);
	std::cout<< "mmap addr = " << addr << std::endl;
	int i;
	std::cin >> i;

	*(int*)addr = 0x1234;

	close(fd);
    }
    else
    {
        perror("Failed at open():");
    }
    return 0;
}

